using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Security.Principal;
using JSC.Portal.Entities.Interfaces;

namespace JSC.Portal.Entities
{
	public partial class PortalPage : DescriptiveEntity, ITracked, IValid
	{
		private string _friendlyUrl;
        
        public PortalPage() : base()
        {
            Sections = new List<Section>();
            ValidFrom = DateTime.Now;
            ChildPages = new List<PortalPage>();
            PagePermissions = new List<PortalPagePermission>();
        }

        public PortalPage Parent
        {
            get;
            set;
        }

		public Template Template
		{
            get;
            set;
		}

        public PortalSite PortalSite
        {
            get;
            set;
        }

        public string Language
        {
            get;
            set;
        }

        public string FriendlyURL
        {
            get
            {
                return _friendlyUrl;
            }
            set
            {
				if (string.IsNullOrEmpty(value))
					_friendlyUrl = null;
				else
					_friendlyUrl = value;
            }
        }

		public int Position
		{
            get;
            set;
		}

		public bool ShowInNavigation
		{
            get;
            set;
		}

		public string MetaKeywords
        {
            get;
            set;
        }

        public string MetaDescription
        {
            get;
            set;
        }

        public IList<Section> Sections
        {
            get;
            set;
        }

        public IList<PortalPage> ChildPages
        {
            get;
            set;
        }

        public IList<PortalPagePermission> PagePermissions
        {
            get;
            set;
        }

        #region ITrackedEntity Members

        public PortalUser CreatedByUser
        {
            get;
            set;
        }

        public PortalUser ModifiedByUser
        {
            get;
            set;
        }

        public DateTime CreatedOn
        {
            get;
            set;
        }

        public DateTime? ModifiedOn
        {
            get;
            set;
        }

        #endregion

        #region IValid Members

        public DateTime ValidFrom
        {
            get;
            set;
        }

        public DateTime? ValidTill
        {
            get;
            set;
        }

        #endregion
    }
}